package Work4.Slay_the_Maze.Events;

import java.util.ArrayList;
import java.util.Scanner;
import java.util.Random;
import Work4.Slay_the_Maze.Cards.*;
import Work4.Slay_the_Maze.Player.*;
import Work4.Slay_the_Maze.Potions.*;
import Work4.Slay_the_Maze.Relics.*;
import Work4.Slay_the_Maze.Events.Interface.*;

public class ChooseEvent1 extends Events implements Umustchoose {
	public ChooseEvent1() {
		super("天降横财","天上掉钱了，这是好事吗？");
	}
	
	@Override
	public void choose(Player player) {
		Printinfo();
		Random rd=new Random();
		Scanner sc=new Scanner(System.in);
		int moneynum=rd.nextInt(61)+10;
		int damagenum=rd.nextInt(11)+10;
		boolean temp=false;
		do {
			System.out.println("做出选择");
			System.out.println("1.接钱:获得"+moneynum+"金币，但受到"+damagenum+"点伤害");
			System.out.println("2.离开:离开这里");
			while (!sc.hasNextInt()) {
			    System.out.println("输入无效，请输入一个整数:");
			    sc.next(); // 清除错误输入，避免死循环
			}
			int choice=sc.nextInt();
			if(choice==1) {
				player.addmoney(moneynum);
				player.damage(damagenum);
				temp=true;
			}else if(choice==2) {
				temp=true;
			}
		}while(!temp);
	}
	
	public void doit(Player player) {
		choose(player);
	}
	
}
